/**
 * @file    base_math.h
 * @brief   基础算法库
 * @author  Liuwei
 * @version 1.0.1
 * @date    2023-04-26
 * 
 * @copyright Copyright (c) 2023 JBD-Energy Storage Technology Co. LTD
 * 
 * @par 修改日志:
 * <table>
 * <tr><th>Date       <th>Version   <th>Author   <th>Description
 * <tr><td>2023-04-17 <td>1.0.1     <td>Liuwei   <td>首次创建
 * </table>
 */

#ifndef __BASE_MATH_H_
#define __BASE_MATH_H_

/* file includes -------------------------------------------------------------*/
#include <stdint.h>
/* cplusplus -----------------------------------------------------------------*/
#ifdef __cplusplus
extern "C" {
#endif

/* macro/define/typedef ------------------------------------------------------*/
typedef struct 
{
    uint8_t min_sn ;
    uint16_t min_val;
    uint8_t max_sn ;
    uint16_t max_val;
}max_min_type;

typedef struct 
{
    uint8_t idx;
    uint16_t data;
}idx_data_type;


#define CALC_MIN(A , B)  ((A)>(B) ? (B):(A))   
#define CALC_MAX(A , B)  ((A)>(B) ? (A):(B))
#define CALC_ARRAY_SIZE(a)  (sizeof(a)/sizeof(a[0]))
#define CALC_ABS(A)      ((A)<(0) ? (-A):(A))
/* variables -----------------------------------------------------------------*/

/*******************************************************************************
 * public API List
 ******************************************************************************/
void math_calc_volt_max(max_min_type *obj , uint8_t size ,uint16_t const *data_buf);
void bubble_sort(uint16_t *src_buf ,uint8_t size, idx_data_type *out_buf);
uint8_t math_cmp_str(const uint8_t str1[],const uint8_t str2[] ,uint16_t len);
uint8_t math_get_data_bit1_num(uint32_t data);

#ifdef __cplusplus
}
#endif

#endif  /* #ifndef __BASE_MATH_H_ */
/********** Copyright (c) 2023 JBD-Energy Storage Technology Co. LTD *********/
